package com.luban.moudle.register;

import com.luban.moudle.emun.Action;
import com.luban.moudle.instance.InstanceInfo;

public class SyncInstanceRegister extends InstanceRegister {

    //责任链
       @Override
    public void register(InstanceInfo info, int timeLimit, boolean isSync) {
        super.register(info, timeLimit, isSync);
        sync(Action.Register,info,null,null,isSync);
    }

    @Override
    public void renew(String appName, String instanceId, boolean isSync) {
        super.renew(appName, instanceId, isSync);
        sync(Action.Renew,null,appName,instanceId,isSync);
    }

    @Override
    public void cancel(String appName, String instanceId, boolean isSync) {
        super.cancel(appName, instanceId, isSync);
        sync(Action.Cancel,null,appName,instanceId,isSync);
    }

    //要注意处理重复同步
    private void sync(Action action,InstanceInfo info,String appName, String instanceId,boolean isSync){
           if (Action.Register.equals(action)){

           }else if (Action.Renew.equals(action)){

           }else  if (Action.Cancel.equals(action)){

           }
           //判断 isSync是否为true
           //判断是什么操作
           //拿到了你配置文件里面其他节点的地址
           //遍历所有节点地址发送请求
    }

}
